package org.hongqi.common.senpec.sys.user;

import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hongqi.common.senpec.base.mybatisplus.IBaseController;
import org.hongqi.common.senpec.base.sevlet.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Collection;

@RestController
@RequiredArgsConstructor
@Slf4j
@RequestMapping("/sys/users")
public class UserController implements IBaseController<User> {
    private final UserService userService;

    @Override
    public Result<User> save(User entity) {
        return userService.mySave(entity);
    }

    @Override
    public Result<?> removeById(Long id) {
        return userService.myRemoveById(id);
    }

    @Override
    public Result<User> updateById(User entity) {
        return userService.myUpdateById(entity);
    }

    @Override
    public Result<User> getById(Long id) {
        return userService.myGetById(id);
    }

    @Override
    public Result<IPage<User>> listObjsWithPage(User entity) {
        return userService.myListObjsWithPage(entity);
    }

    @Override
    public Result<Collection<User>> listObjsWithoutPage(User entity) {
        return userService.myListObjsWithoutPage(entity);
    }

    @Override
    public void exportObjs(HttpServletResponse response) {
        userService.myExportObjs(response);
    }

    @Override
    public void importObjs(Long creator, MultipartFile file) throws IOException {
        userService.myImportObjs(creator, file);
    }


}
